Repository navigation
[docs] Fix imports that fail on main in four English docs - #50817
Merged
Rocketknight1 merged 1 commit intoNov 16, 2026
Merged
Conversation
- tapas.md: AdamW was removed from transformers; import it from torch.optim - trocr.md: BitsandBytesConfig -> BitsAndBytesConfig - persimmon.md: there is no PersimmonTokenizer; load it with AutoTokenizer - testing.md: MemoryCleanupMixin lives in tests/test_memory_cleanup_mixin.py, not transformers.testing_utils; also import unittest, which the snippet uses
Rocketknight1
enabled auto-merge
November 16, 2026 13:30
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. Pages changed in this PR: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Four code examples in the English docs fail on their import line on current
main. This PR fixes all four in one go.This is the single bulk PR proposed in #50793, following the suggestion on #50607. That issue has the sweep script and its full output. It checked all 1,750
from transformers... import ...statements indocs/source/en(3,050 names). Apart from 12 deliberate placeholders (MyModel,MyVLM*,BrandNewLlama*), five names do not exist: these four, plusinfer_deviceintasks/any_to_any.md, which is already fixed in #50792.mainmodel_doc/tapas.mdfrom transformers import AdamW, ...(removed from transformers)from torch.optim import AdamWmodel_doc/trocr.mdBitsandBytesConfig(typo,ImportError)BitsAndBytesConfigmodel_doc/persimmon.mdfrom transformers import ..., PersimmonTokenizer(no such class)AutoTokenizer. The checkpoint'stokenizer_config.jsondeclaresLlamaTokenizer, which the note under the example also mentionstesting.mdfrom transformers.testing_utils import MemoryCleanupMixin, ...from ...test_memory_cleanup_mixin import MemoryCleanupMixin, the import the test files use. The mixin lives intests/test_memory_cleanup_mixin.py, as the next section of the page already says. I also addedimport unittest, since the snippet subclassesunittest.TestCaseOnly the English pages are changed, since the other languages are machine-translated (#50120). There are no code changes.
flowchart TD A[Sweep every transformers import in docs/source/en] --> B[5 names that do not exist] B --> C[any_to_any infer_device: fixed in 50792] B --> D[tapas, trocr, persimmon, testing: this PR] D -->|Before| E[ImportError on the first line of each example] D -->|After| F[Each block's imports run, sweep finds only the any_to_any line]Narrated recording, main then branch (sound on). I shortened the two-minute wait while the Persimmon tokenizer converts; every command and every line of output is still shown:
evidence_upload.mp4
Reproducer
check_block.py(not part of the PR) takes a file at a git ref, finds the fenced code block that contains a given string, and runs that block's import lines. Withfullit runs the whole block instead. It runs them as a module undertests/models/, so the relative import that test files use resolves. Run from the repo root withPYTHONPATH=src, CPU only.On
main(cf13eb9):On this branch, the same three model-doc blocks print
=> OK. Thetesting.mdblock, run whole withfull, definesMyModelIntegrationTest(MemoryCleanupMixin, unittest.TestCase)and prints=> OK.For Persimmon,
AutoTokenizerloads the real checkpoint's tokenizer:The sweep, on a
git archiveofmainand then on this branch, with the placeholders filtered out:Checks
python utils/checkers.py ruff_check,ruff_format,init_isort,sort_auto_mappings,noisy_comments,doc_toc,doctest_list --no-cache: all 7 passed.git diff --checkis clean.add_datesnot run usefully: my clone is shallow, so it reads every model card's first commit as the clone date and flags any card it touches. The dates lines are unchanged in this PR.AI assistance (Claude Code) was used to find the broken imports, make the change, run the checks above and record the video.
Who can review?
Documentation: @stevhliu
Fixes #50793